import asyncio
import time
from functools import partial


async def get_html(url):
    print("start!!")
    await asyncio.sleep(2)
    print("end")
    return "leo"


def callback(url, future):
    print(url)
    print("send email to leo")


if __name__ == '__main__':
    start = time.time()
    loop = asyncio.get_event_loop()
    # get_future = asyncio.ensure_future(get_html("www.test.com"))
    task = loop.create_task(get_html("www.test.com"))
    task.add_done_callback(partial(callback, "www.test.com"))

    loop.run_until_complete(task)
    print(time.time() - start)
    print(task.result())